38 plotly
Uncomment the following line to install leafmap if needed.
# !pip install leafmap
import leafmap.plotlymap as leafmap
If you run into an error saying "FigureWidget - 'mapbox._derived' Value Error" (source), uncomment the following line and run it.
# leafmap.fix_widget_error()
Create an interactive map using default settings.
m = leafmap.Map()
m
Change default setting when creating a map.
Can be one of string from "open-street-map", "carto-positron", "carto-darkmatter", "stamen-terrain", "stamen-toner" or "stamen-watercolor" .
m = leafmap.Map(center=(40, -100), zoom=3, basemap="stamen-terrain", height=500)
m
Set map center and zoom level.
m = leafmap.Map(basemap="stamen-watercolor")
m.set_center(lat=20, lon=0, zoom=2)
m
Print out available basemaps.
leafmap.basemaps.keys()
dict_keys(['OpenStreetMap', 'ROADMAP', 'SATELLITE', 'TERRAIN', 'HYBRID', 'BasemapAT.basemap', 'BasemapAT.grau', 'BasemapAT.highdpi', 'BasemapAT.orthofoto', 'BasemapAT.overlay', 'BasemapAT.surface', 'BasemapAT.terrain', 'CartoDB.DarkMatter', 'CartoDB.DarkMatterNoLabels', 'CartoDB.DarkMatterOnlyLabels', 'CartoDB.Positron', 'CartoDB.PositronNoLabels', 'CartoDB.PositronOnlyLabels', 'CartoDB.Voyager', 'CartoDB.VoyagerLabelsUnder', 'CartoDB.VoyagerNoLabels', 'CartoDB.VoyagerOnlyLabels', 'CyclOSM', 'Esri.AntarcticBasemap', 'Esri.AntarcticImagery', 'Esri.ArcticImagery', 'Esri.ArcticOceanBase', 'Esri.ArcticOceanReference', 'Esri.DeLorme', 'Esri.NatGeoWorldMap', 'Esri.OceanBasemap', 'Esri.WorldGrayCanvas', 'Esri.WorldImagery', 'Esri.WorldPhysical', 'Esri.WorldShadedRelief', 'Esri.WorldStreetMap', 'Esri.WorldTerrain', 'Esri.WorldTopoMap', 'FreeMapSK', 'Gaode.Normal', 'Gaode.Satellite', 'GeoportailFrance.Adminexpress_cog_Latest', 'GeoportailFrance.Adminexpress_cog_carto_Latest', 'GeoportailFrance.Areamanagement_Zfu', 'GeoportailFrance.Areamanagement_Zus', 'GeoportailFrance.Bdcarto_etat_major_Niveau3', 'GeoportailFrance.Bdcarto_etat_major_Niveau4', 'GeoportailFrance.Buildings_Buildings', 'GeoportailFrance.Communes_Prioritydisctrict', 'GeoportailFrance.Dreal_Zonage_pinel', 'GeoportailFrance.Elevation_Contour_Line', 'GeoportailFrance.Elevation_Elevationgridcoverage_Shadow', 'GeoportailFrance.Elevation_Elevationgridcoverage_Threshold', 'GeoportailFrance.Elevation_Level0', 'GeoportailFrance.Elevation_Slopes', 'GeoportailFrance.Elevationgridcoverage_Highres_Quality', 'GeoportailFrance.Forets_Publiques', 'GeoportailFrance.Geographicalgridsystem_Dfci', 'GeoportailFrance.Geographicalgridsystems_1900typemaps', 'GeoportailFrance.Geographicalgridsystems_Bonne', 'GeoportailFrance.Geographicalgridsystems_Etatmajor10', 'GeoportailFrance.Geographicalgridsystems_Etatmajor40', 'GeoportailFrance.Geographicalgridsystems_Maps_Bduni_J1', 'GeoportailFrance.Geographicalgridsystems_Maps_Overview', 'GeoportailFrance.Geographicalgridsystems_Maps_Scan50_1950', 'GeoportailFrance.Geographicalgridsystems_Slopes_Mountain', 'GeoportailFrance.Geographicalgridsystems_Slopes_Pac', 'GeoportailFrance.Geographicalgridsystems_Terrier_v1', 'GeoportailFrance.Geographicalgridsystems_Terrier_v2', 'GeoportailFrance.Geographicalnames_Names', 'GeoportailFrance.Hedge_Hedge', 'GeoportailFrance.Hr_Orthoimagery_Orthophotos', 'GeoportailFrance.Hydrography_Bcae_2022', 'GeoportailFrance.Hydrography_Bcae_Latest', 'GeoportailFrance.Hydrography_Hydrography', 'GeoportailFrance.Insee_Filosofi_Enfants_0_17_Ans_Secret', 'GeoportailFrance.Insee_Filosofi_Logements_Surface_Moyenne_Secret', 'GeoportailFrance.Insee_Filosofi_Niveau_De_Vie_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Familles_Monoparentales_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Individus_25_39_Ans_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Individus_40_54_Ans_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Individus_55_64_Ans_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Logements_Apres_1990_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Logements_Avant_1945_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Logements_Collectifs_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Logements_Construits_1945_1970_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Logements_Construits_1970_1990_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Logements_Sociaux_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Menages_1_Personne_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Menages_5_Personnes_Ouplus_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Menages_Maison_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Menages_Pauvres_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Menages_Proprietaires_Secret', 'GeoportailFrance.Insee_Filosofi_Part_Plus_65_Ans_Secret', 'GeoportailFrance.Insee_Filosofi_Population', 'GeoportailFrance.Landcover_Cha00_fr', 'GeoportailFrance.Landcover_Cha06_dom', 'GeoportailFrance.Landcover_Cha06_fr', 'GeoportailFrance.Landcover_Cha12_dom', 'GeoportailFrance.Landcover_Cha12_fr', 'GeoportailFrance.Landcover_Cha18', 'GeoportailFrance.Landcover_Cha18_dom', 'GeoportailFrance.Landcover_Cha18_fr', 'GeoportailFrance.Landcover_Clc00_dom', 'GeoportailFrance.Landcover_Clc00_fr', 'GeoportailFrance.Landcover_Clc00r_fr', 'GeoportailFrance.Landcover_Clc06_dom', 'GeoportailFrance.Landcover_Clc06_fr', 'GeoportailFrance.Landcover_Clc06r_dom', 'GeoportailFrance.Landcover_Clc06r_fr', 'GeoportailFrance.Landcover_Clc12', 'GeoportailFrance.Landcover_Clc12_dom', 'GeoportailFrance.Landcover_Clc12_fr', 'GeoportailFrance.Landcover_Clc12r', 'GeoportailFrance.Landcover_Clc12r_dom', 'GeoportailFrance.Landcover_Clc12r_fr', 'GeoportailFrance.Landcover_Clc18', 'GeoportailFrance.Landcover_Clc18_dom', 'GeoportailFrance.Landcover_Clc18_fr', 'GeoportailFrance.Landcover_Clc90_fr', 'GeoportailFrance.Landcover_Forestareas', 'GeoportailFrance.Landcover_Forestinventory_V1', 'GeoportailFrance.Landcover_Forestinventory_V2', 'GeoportailFrance.Landcover_Grid_Clc00', 'GeoportailFrance.Landcover_Grid_Clc00_dom', 'GeoportailFrance.Landcover_Grid_Clc00_fr', 'GeoportailFrance.Landcover_Grid_Clc00r_fr', 'GeoportailFrance.Landcover_Grid_Clc06', 'GeoportailFrance.Landcover_Grid_Clc06_dom', 'GeoportailFrance.Landcover_Grid_Clc06_fr', 'GeoportailFrance.Landcover_Grid_Clc06r', 'GeoportailFrance.Landcover_Grid_Clc06r_dom', 'GeoportailFrance.Landcover_Grid_Clc06r_fr', 'GeoportailFrance.Landcover_Grid_Clc12', 'GeoportailFrance.Landcover_Grid_Clc90_fr', 'GeoportailFrance.Landcover_Hr_Dlt_Clc12', 'GeoportailFrance.Landcover_Hr_Dlt_Clc15', 'GeoportailFrance.Landcover_Hr_Gra_Clc15', 'GeoportailFrance.Landcover_Hr_Imd_Clc12', 'GeoportailFrance.Landcover_Hr_Imd_Clc15', 'GeoportailFrance.Landcover_Hr_Tcd_Clc12', 'GeoportailFrance.Landcover_Hr_Tcd_Clc15', 'GeoportailFrance.Landcover_Hr_Waw_Clc15', 'GeoportailFrance.Landcover_Sylvoecoregions', 'GeoportailFrance.Landcover_Sylvoecoregions_Alluvium', 'GeoportailFrance.Landuse_Agriculture2007', 'GeoportailFrance.Landuse_Agriculture2008', 'GeoportailFrance.Landuse_Agriculture2009', 'GeoportailFrance.Landuse_Agriculture2010', 'GeoportailFrance.Landuse_Agriculture2011', 'GeoportailFrance.Landuse_Agriculture2012', 'GeoportailFrance.Landuse_Agriculture2013', 'GeoportailFrance.Landuse_Agriculture2014', 'GeoportailFrance.Landuse_Agriculture2015', 'GeoportailFrance.Landuse_Agriculture2016', 'GeoportailFrance.Landuse_Agriculture2017', 'GeoportailFrance.Landuse_Agriculture2018', 'GeoportailFrance.Landuse_Agriculture2019', 'GeoportailFrance.Landuse_Agriculture2020', 'GeoportailFrance.Limites_administratives_express_Latest', 'GeoportailFrance.Ocsge_Constructions', 'GeoportailFrance.Ocsge_Constructions_2002', 'GeoportailFrance.Ocsge_Constructions_2014', 'GeoportailFrance.Ocsge_Constructions_2016', 'GeoportailFrance.Ocsge_Constructions_2019', 'GeoportailFrance.Ocsge_Couverture', 'GeoportailFrance.Ocsge_Couverture_2002', 'GeoportailFrance.Ocsge_Couverture_2014', 'GeoportailFrance.Ocsge_Couverture_2016', 'GeoportailFrance.Ocsge_Couverture_2019', 'GeoportailFrance.Ocsge_Usage', 'GeoportailFrance.Ocsge_Usage_2002', 'GeoportailFrance.Ocsge_Usage_2014', 'GeoportailFrance.Ocsge_Usage_2016', 'GeoportailFrance.Ocsge_Usage_2019', 'GeoportailFrance.Ocsge_Visu_2016', 'GeoportailFrance.Ocsge_Visu_2019', 'GeoportailFrance.Ortho-sat-rapideye-2010_pyr-jpeg_wld_wm_20160801', 'GeoportailFrance.Ortho-sat-rapideye-2011_pyr-jpeg_wld_wm_2011', 'GeoportailFrance.Orthoimagery_Ortho_sat_Pleiades_2012', 'GeoportailFrance.Orthoimagery_Ortho_sat_Pleiades_2013', 'GeoportailFrance.Orthoimagery_Ortho_sat_Pleiades_2014', 'GeoportailFrance.Orthoimagery_Ortho_sat_Pleiades_2015', 'GeoportailFrance.Orthoimagery_Ortho_sat_Pleiades_2016', 'GeoportailFrance.Orthoimagery_Ortho_sat_Pleiades_2017', 'GeoportailFrance.Orthoimagery_Ortho_sat_Pleiades_2018', 'GeoportailFrance.Orthoimagery_Ortho_sat_Pleiades_2019', 'GeoportailFrance.Orthoimagery_Ortho_sat_Pleiades_2020', 'GeoportailFrance.Orthoimagery_Ortho_sat_Pleiades_2021', 'GeoportailFrance.Orthoimagery_Ortho_sat_Pleiades_2022', 'GeoportailFrance.Orthoimagery_Ortho_sat_Rapideye_2010', 'GeoportailFrance.Orthoimagery_Ortho_sat_Rapideye_2011', 'GeoportailFrance.Orthoimagery_Ortho_sat_Spot_2013', 'GeoportailFrance.Orthoimagery_Ortho_sat_Spot_2014', 'GeoportailFrance.Orthoimagery_Ortho_sat_Spot_2015', 'GeoportailFrance.Orthoimagery_Ortho_sat_Spot_2016', 'GeoportailFrance.Orthoimagery_Ortho_sat_Spot_2017', 'GeoportailFrance.Orthoimagery_Ortho_sat_Spot_2018', 'GeoportailFrance.Orthoimagery_Ortho_sat_Spot_2019', 'GeoportailFrance.Orthoimagery_Ortho_sat_Spot_2020', 'GeoportailFrance.Orthoimagery_Ortho_sat_Spot_2021', 'GeoportailFrance.Orthoimagery_Orthophos_Restrictedareas', 'GeoportailFrance.Orthoimagery_Orthophotos2000', 'GeoportailFrance.Orthoimagery_Orthophotos2000_2005', 'GeoportailFrance.Orthoimagery_Orthophotos2001', 'GeoportailFrance.Orthoimagery_Orthophotos2002', 'GeoportailFrance.Orthoimagery_Orthophotos2003', 'GeoportailFrance.Orthoimagery_Orthophotos2004', 'GeoportailFrance.Orthoimagery_Orthophotos2005', 'GeoportailFrance.Orthoimagery_Orthophotos2006', 'GeoportailFrance.Orthoimagery_Orthophotos2006_2010', 'GeoportailFrance.Orthoimagery_Orthophotos2007', 'GeoportailFrance.Orthoimagery_Orthophotos2008', 'GeoportailFrance.Orthoimagery_Orthophotos2009', 'GeoportailFrance.Orthoimagery_Orthophotos2010', 'GeoportailFrance.Orthoimagery_Orthophotos2011', 'GeoportailFrance.Orthoimagery_Orthophotos2011_2015', 'GeoportailFrance.Orthoimagery_Orthophotos2012', 'GeoportailFrance.Orthoimagery_Orthophotos2013', 'GeoportailFrance.Orthoimagery_Orthophotos2014', 'GeoportailFrance.Orthoimagery_Orthophotos2015', 'GeoportailFrance.Orthoimagery_Orthophotos2016', 'GeoportailFrance.Orthoimagery_Orthophotos2017', 'GeoportailFrance.Orthoimagery_Orthophotos2018', 'GeoportailFrance.Orthoimagery_Orthophotos2019', 'GeoportailFrance.Orthoimagery_Orthophotos2020', 'GeoportailFrance.Orthoimagery_Orthophotos_1950_1965', 'GeoportailFrance.Orthoimagery_Orthophotos_1980_1995', 'GeoportailFrance.Orthoimagery_Orthophotos_Bdortho', 'GeoportailFrance.Orthoimagery_Orthophotos_Coast2000', 'GeoportailFrance.Orthoimagery_Orthophotos_Ilesdunord', 'GeoportailFrance.Orthoimagery_Orthophotos_Irc', 'GeoportailFrance.Orthoimagery_Orthophotos_Irc_2013', 'GeoportailFrance.Orthoimagery_Orthophotos_Irc_2014', 'GeoportailFrance.Orthoimagery_Orthophotos_Irc_2015', 'GeoportailFrance.Orthoimagery_Orthophotos_Irc_2016', 'GeoportailFrance.Orthoimagery_Orthophotos_Irc_2017', 'GeoportailFrance.Orthoimagery_Orthophotos_Irc_2018', 'GeoportailFrance.Orthoimagery_Orthophotos_Irc_2019', 'GeoportailFrance.Orthoimagery_Orthophotos_Irc_2020', 'GeoportailFrance.Orthoimagery_Orthophotos_Irc_express_2018', 'GeoportailFrance.Orthoimagery_Orthophotos_Irc_express_2019', 'GeoportailFrance.Orthoimagery_Orthophotos_Irc_express_2020', 'GeoportailFrance.Orthoimagery_Orthophotos_Irc_express_2021', 'GeoportailFrance.Orthoimagery_Orthophotos_Irc_express_2022', 'GeoportailFrance.Orthoimagery_Orthophotos_Ortho_asp_pac2020', 'GeoportailFrance.Orthoimagery_Orthophotos_Ortho_asp_pac2021', 'GeoportailFrance.Orthoimagery_Orthophotos_Ortho_asp_pac2022', 'GeoportailFrance.Orthoimagery_Orthophotos_Ortho_express_2017', 'GeoportailFrance.Orthoimagery_Orthophotos_Ortho_express_2019', 'GeoportailFrance.Orthoimagery_Orthophotos_Ortho_express_2020', 'GeoportailFrance.Orthoimagery_Orthophotos_Ortho_express_2021', 'GeoportailFrance.Orthoimagery_Orthophotos_Ortho_express_2022', 'GeoportailFrance.Orthoimagery_Orthophotos_Socle_asp_2018', 'GeoportailFrance.Orthoimagery_Orthophotos_Urgence_Alex', 'GeoportailFrance.Pcrs_Lamb93', 'GeoportailFrance.Protectedareas_Apb', 'GeoportailFrance.Protectedareas_Apg', 'GeoportailFrance.Protectedareas_Aphn', 'GeoportailFrance.Protectedareas_Bios', 'GeoportailFrance.Protectedareas_Gp', 'GeoportailFrance.Protectedareas_Inpg', 'GeoportailFrance.Protectedareas_Mnhn_Cdl_Parcels', 'GeoportailFrance.Protectedareas_Mnhn_Cdl_Perimeter', 'GeoportailFrance.Protectedareas_Mnhn_Conservatoires', 'GeoportailFrance.Protectedareas_Mnhn_Rn_Perimeter', 'GeoportailFrance.Protectedareas_Pn', 'GeoportailFrance.Protectedareas_Pnm', 'GeoportailFrance.Protectedareas_Pnr', 'GeoportailFrance.Protectedareas_Prsf', 'GeoportailFrance.Protectedareas_Ramsar', 'GeoportailFrance.Protectedareas_Rb', 'GeoportailFrance.Protectedareas_Ripn', 'GeoportailFrance.Protectedareas_Rn', 'GeoportailFrance.Protectedareas_Rnc', 'GeoportailFrance.Protectedareas_Rncf', 'GeoportailFrance.Protectedareas_Sic', 'GeoportailFrance.Protectedareas_Znieff1', 'GeoportailFrance.Protectedareas_Znieff1_Sea', 'GeoportailFrance.Protectedareas_Znieff2', 'GeoportailFrance.Protectedareas_Znieff2_Sea', 'GeoportailFrance.Protectedareas_Zps', 'GeoportailFrance.Protectedsites_Mnhn_Reserves_regionales', 'GeoportailFrance.Securoute_Te_1te', 'GeoportailFrance.Securoute_Te_2te48', 'GeoportailFrance.Securoute_Te_All', 'GeoportailFrance.Securoute_Te_Oa', 'GeoportailFrance.Securoute_Te_Pn', 'GeoportailFrance.Securoute_Te_Pnd', 'GeoportailFrance.Securoute_Te_Te120', 'GeoportailFrance.Securoute_Te_Te72', 'GeoportailFrance.Securoute_Te_Te94', 'GeoportailFrance.Thr_Orthoimagery_Orthophotos', 'GeoportailFrance.Transportnetwork_Commontransportelements_Markerpost', 'GeoportailFrance.Transportnetworks_Railways', 'GeoportailFrance.Transportnetworks_Roads', 'GeoportailFrance.Transportnetworks_Roads_Direction', 'GeoportailFrance.Transportnetworks_Runways', 'GeoportailFrance.Transports_Drones_Restrictions', 'GeoportailFrance.Utilityandgovernmentalservices_All', 'GeoportailFrance.orthos', 'GeoportailFrance.parcels', 'GeoportailFrance.plan', 'HikeBike.HikeBike', 'HikeBike.HillShading', 'JusticeMap.americanIndian', 'JusticeMap.asian', 'JusticeMap.black', 'JusticeMap.hispanic', 'JusticeMap.income', 'JusticeMap.multi', 'JusticeMap.nonWhite', 'JusticeMap.plurality', 'JusticeMap.white', 'MtbMap', 'NASAGIBS.ASTER_GDEM_Greyscale_Shaded_Relief', 'NASAGIBS.BlueMarble', 'NASAGIBS.BlueMarble3031', 'NASAGIBS.BlueMarble3413', 'NASAGIBS.ModisAquaBands721CR', 'NASAGIBS.ModisAquaTrueColorCR', 'NASAGIBS.ModisTerraAOD', 'NASAGIBS.ModisTerraBands367CR', 'NASAGIBS.ModisTerraBands721CR', 'NASAGIBS.ModisTerraChlorophyll', 'NASAGIBS.ModisTerraLSTDay', 'NASAGIBS.ModisTerraSnowCover', 'NASAGIBS.ModisTerraTrueColorCR', 'NASAGIBS.ViirsEarthAtNight2012', 'NASAGIBS.ViirsTrueColorCR', 'NLS', 'OPNVKarte', 'OneMapSG.Default', 'OneMapSG.Grey', 'OneMapSG.LandLot', 'OneMapSG.Night', 'OneMapSG.Original', 'OpenAIP', 'OpenFireMap', 'OpenRailwayMap', 'OpenSeaMap', 'OpenSnowMap.pistes', 'OpenStreetMap.BZH', 'OpenStreetMap.BlackAndWhite', 'OpenStreetMap.CH', 'OpenStreetMap.DE', 'OpenStreetMap.France', 'OpenStreetMap.HOT', 'OpenStreetMap.Mapnik', 'OpenTopoMap', 'SafeCast', 'Stadia.AlidadeSmooth', 'Stadia.AlidadeSmoothDark', 'Stadia.OSMBright', 'Stadia.Outdoors', 'Stamen.Terrain', 'Stamen.TerrainBackground', 'Stamen.TerrainLabels', 'Stamen.Toner', 'Stamen.TonerBackground', 'Stamen.TonerHybrid', 'Stamen.TonerLabels', 'Stamen.TonerLines', 'Stamen.TonerLite', 'Stamen.TopOSMFeatures', 'Stamen.TopOSMRelief', 'Stamen.Watercolor', 'Strava.All', 'Strava.Ride', 'Strava.Run', 'Strava.Water', 'Strava.Winter', 'SwissFederalGeoportal.JourneyThroughTime', 'SwissFederalGeoportal.NationalMapColor', 'SwissFederalGeoportal.NationalMapGrey', 'SwissFederalGeoportal.SWISSIMAGE', 'USGS.USImagery', 'USGS.USImageryTopo', 'USGS.USTopo', 'WaymarkedTrails.cycling', 'WaymarkedTrails.hiking', 'WaymarkedTrails.mtb', 'WaymarkedTrails.riding', 'WaymarkedTrails.skating', 'WaymarkedTrails.slopes', 'nlmaps.grijs', 'nlmaps.luchtfoto', 'nlmaps.pastel', 'nlmaps.standaard', 'nlmaps.water'])
Add a basemap.
m = leafmap.Map()
m.add_basemap("OpenTopoMap")
m
Add XYZ tile layer.
m = leafmap.Map()
tile_url = "https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}"
m.add_tile_layer(tile_url, name="Google Satellite", attribution="Google", opacity=1.0)
m
Add a mapbox tile layer. You will need a mapbox token. The map style can be Can be "basic", "streets", "outdoors", "light", "dark", "satellite", or "satellite-streets".
import os
# os.environ["MAPBOX_TOKEN"] = "your-mapbox-token"
m = leafmap.Map()
m.add_mapbox_layer(style="streets")
m
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In [12], line 2 1 m = leafmap.Map() ----> 2 m.add_mapbox_layer(style="streets") 3 m File /opt/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/site-packages/leafmap/plotlymap.py:222, in Map.add_mapbox_layer(self, style, access_token) 219 if access_token is None: 220 access_token = os.environ.get("MAPBOX_TOKEN") --> 222 self.update_layout( 223 mapbox_style=style, mapbox_layers=[], mapbox_accesstoken=access_token 224 ) File /opt/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/site-packages/plotly/graph_objs/_figurewidget.py:756, in FigureWidget.update_layout(self, dict1, overwrite, **kwargs) 730 def update_layout(self, dict1=None, overwrite=False, **kwargs) -> "FigureWidget": 731 """ 732 733 Update the properties of the figure's layout with a dict and/or with (...) 754 755 """ --> 756 return super(FigureWidget, self).update_layout(dict1, overwrite, **kwargs) File /opt/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/site-packages/plotly/basedatatypes.py:1401, in BaseFigure.update_layout(self, dict1, overwrite, **kwargs) 1377 def update_layout(self, dict1=None, overwrite=False, **kwargs): 1378 """ 1379 Update the properties of the figure's layout with a dict and/or with 1380 keyword arguments. (...) 1399 The Figure object that the update_layout method was called on 1400 """ -> 1401 self.layout.update(dict1, overwrite=overwrite, **kwargs) 1402 return self File /opt/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/site-packages/plotly/basedatatypes.py:5122, in BasePlotlyType.update(self, dict1, overwrite, **kwargs) 5120 with self.figure.batch_update(): 5121 BaseFigure._perform_update(self, dict1, overwrite=overwrite) -> 5122 BaseFigure._perform_update(self, kwargs, overwrite=overwrite) 5123 else: 5124 BaseFigure._perform_update(self, dict1, overwrite=overwrite) File /opt/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/site-packages/plotly/basedatatypes.py:3929, in BaseFigure._perform_update(plotly_obj, update_obj, overwrite) 3926 plotly_obj[key] = val 3927 else: 3928 # Assign non-compound value -> 3929 plotly_obj[key] = val 3931 elif isinstance(plotly_obj, tuple): 3933 if len(update_obj) == 0: 3934 # Nothing to do File /opt/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/site-packages/plotly/basedatatypes.py:5850, in BaseLayoutType.__setitem__(self, prop, value) 5847 prop_tuple = BaseFigure._str_to_dict_path(prop) 5848 if len(prop_tuple) != 1 or not isinstance(prop_tuple[0], str): 5849 # Let parent handle non-scalar non-string cases -> 5850 super(BaseLayoutHierarchyType, self).__setitem__(prop, value) 5851 return 5852 else: 5853 # Unwrap prop tuple File /opt/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/site-packages/plotly/basedatatypes.py:4899, in BasePlotlyType.__setitem__(self, prop, value) 4895 res = res[p] 4897 res._validate = self._validate -> 4899 res[prop[-1]] = value File /opt/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/site-packages/plotly/basedatatypes.py:4859, in BasePlotlyType.__setitem__(self, prop, value) 4855 self._set_array_prop(prop, value) 4857 # ### Handle simple property ### 4858 else: -> 4859 self._set_prop(prop, value) 4860 else: 4861 # Make sure properties dict is initialized 4862 self._init_props() File /opt/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/site-packages/plotly/basedatatypes.py:5203, in BasePlotlyType._set_prop(self, prop, val) 5201 return 5202 else: -> 5203 raise err 5205 # val is None 5206 # ----------- 5207 if val is None: 5208 # Check if we should send null update File /opt/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/site-packages/plotly/basedatatypes.py:5198, in BasePlotlyType._set_prop(self, prop, val) 5195 validator = self._get_validator(prop) 5197 try: -> 5198 val = validator.validate_coerce(val) 5199 except ValueError as err: 5200 if self._skip_invalid: File /opt/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/site-packages/_plotly_utils/basevalidators.py:1099, in StringValidator.validate_coerce(self, v) 1096 self.raise_invalid_val(v) 1098 if self.no_blank and len(v) == 0: -> 1099 self.raise_invalid_val(v) 1101 if self.values and v not in self.values: 1102 self.raise_invalid_val(v) File /opt/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/site-packages/_plotly_utils/basevalidators.py:288, in BaseValidator.raise_invalid_val(self, v, inds) 285 for i in inds: 286 name += "[" + str(i) + "]" --> 288 raise ValueError( 289 """ 290 Invalid value of type {typ} received for the '{name}' property of {pname} 291 Received value: {v} 292 293 {valid_clr_desc}""".format( 294 name=name, 295 pname=self.parent_name, 296 typ=type_str(v), 297 v=repr(v), 298 valid_clr_desc=self.description(), 299 ) 300 ) ValueError: Invalid value of type 'builtins.str' received for the 'accesstoken' property of layout.mapbox Received value: '' The 'accesstoken' property is a string and must be specified as: - A non-empty string
Remove the modebar in the upper-right corner.
m = leafmap.Map(basemap="stamen-toner")
m
m.clear_controls()
Add more buttons to the modebar.
m = leafmap.Map(basemap="carto-positron")
controls = [
'drawline',
'drawopenpath',
'drawclosedpath',
'drawcircle',
'drawrect',
'eraseshape',
]
m.add_controls(controls)
m
Add Cloud Optimized GeoTIFF.
m = leafmap.Map()
url = 'https://opendata.digitalglobe.com/events/california-fire-2020/pre-event/2018-02-16/pine-gulch-fire20/1030010076004E00.tif'
m.add_cog_layer(url, name="Fire (pre-event)")
m
Add a STAC item via HTTP URL.
m = leafmap.Map()
url = 'https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json'
m.add_stac_layer(url, bands=['B3', 'B2', 'B1'], name='False color')
m
Add a STAC item from Microsoft Planetary Computer.
collection = "landsat-8-c2-l2"
item = "LC08_L2SP_047027_20201204_02_T1"
m = leafmap.Map()
m.add_stac_layer(
collection=collection,
item=item,
bands=["SR_B7", "SR_B5", "SR_B4"],
titiler_endpoint="pc",
)
m
Add a heat map.
url = 'https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv'
m = leafmap.Map(basemap="stamen-terrain")
m.add_heatmap(
url, latitude="Latitude", longitude="Longitude", z="Magnitude", name="Earthquake"
)
m
Add a choropleth map.
url = "https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/countries.geojson"
m = leafmap.Map(basemap="stamen-terrain")
m.add_choropleth_map(url, name="Pop", z="POP_EST", colorscale="Viridis")
m